<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" import="net.fckeditor.*" %>
<%@ taglib uri="http://java.fckeditor.net" prefix="FCK" %>

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>

<html>
	<head>
		<title></title>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<script type="text/javascript" src="${ctx}/jquery/jquery-js/jquery-1.3.2.min.js"></script>
		<link href="<c:out value='${ctx}'/>/css/style.css" rel="stylesheet" type="text/css">
		<%
			FCKeditor fckEditor = new FCKeditor(request, "EditorDefault");
			fckEditor.setHeight("100%");
		%>
		<script type="text/javascript">
			var $j = jQuery.noConflict();
			$j(function() {
				$j("#testBtn").click(function() {
					var oEditor = FCKeditorAPI.GetInstance('content');
				    var content = oEditor.GetXHTML(true);

				    var url = "${ctx}/admin/visa/ContentEditorAction/save.action";
					var data = {content:content, id:$j('#id').val(), tableName:$j("#tableName").val()};
					$j.post(url,data,function(data,status) {
						if(data.result == 'success') {
							alert('保存成功！');
							var url = "${ctx}/admin/visa/ContentEditorAction/showPreview.action?id=" + $j('#id').val() + "&tableName=" + $j("#tableName").val();
							window.location.href = url;
						}
						else {
							alert('保存失败！');
						}
					},'json');
				});
			});
		</script>
		<script type="text/javascript">
			function FCKeditor_OnComplete(editorInstance) {
				window.status = editorInstance.Description;
			}
		</script>
	</head>
	<body style="overflow: hidden">
		
		<form id="contentForm" action="#" method="post" target="_blank">
		<input type="hidden" id="id" name="id" value="${param.id}">
		<input type="hidden" id="tableName" name="tableName" value="${param.tableName}">
		<table width="100%" height="100%" border="0">
			<tr valign="top">
				<td width="100%" height="100%">
					<%
						fckEditor.setHeight("450");
						fckEditor.setInstanceName("content");
						String content = (String)request.getAttribute("content");
						fckEditor.setValue(content);
						out.println(fckEditor);
					%>
				</td>
			</tr>
			<tr>
				<td height="30px" align="center">
					<input type="button" id="testBtn" value="保存" class="button" onmouseover="this.className='buttonover'" onmouseout="this.className='button'">
				</td>
			</tr>
		</table>
		</form>
	</body>
</html>
		